package com.hl.springboothome1.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.springboothome1.entity.Article;
import com.hl.springboothome1.mapper.ArticleMapper;
import com.hl.springboothome1.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    ArticleMapper articleMapper;

    @Override
    public int add(Article article) {
        int i = articleMapper.add(article);
        return i;
    }

    @Override
    public int deleteById(int id) {
        int i = articleMapper.deleteById(id);
        return i;
    }

    @Override
    public int deleteBatch(List list) {
        int i = articleMapper.deleteBatch(list);
        return i;
    }

    @Override
    public int update(Article article) {
        int update = articleMapper.update(article);
        return update;
    }

    @Override
    public Article selectById(int id) {
        Article article = articleMapper.selectById(id);
        return article;
    }

    @Override
    public PageInfo<Article> selectAll(Article article,int pageNum,int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Article> articles = articleMapper.selectAll(article);
        PageInfo<Article> articlePageInfo = new PageInfo<>(articles);
        return articlePageInfo;
    }
}
